package org.unt.logic;

import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

public class StringLogic {

    public static String duplicateSinglesQuotes(String str) {

        if (str == null || str.trim().equals("")) {
            return str;
        }

        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < str.length(); i++) {

            if (str.charAt(i) != '\'') {
                buf.append(str.charAt(i));
            } else {
                buf.append('\'');
                buf.append('\'');
            }
        }

        return buf.toString();
    }

    public static Properties load(String propsName) throws Exception {

        Properties props = new Properties();
        URL url = ClassLoader.getSystemResource(propsName);
        InputStream is = url.openStream();
        props.load(is);

        return props;
    }

    public static void printChars(String str) {
        for (int i = 0; i < str.length(); i++) {
            System.out.println(str.charAt(i) + "\t" + (int) str.charAt(i));
        }
    }
}
